5. The Default Page
Consider the virtual directory http://localhost/MySite. A user can request a specific page in this directory using a URL such as http://localhost/MySite/MyPage1.aspx. But what happens if the user simply types http://localhost/MySite into a web browser?
In this case, IIS will examine the list of default documents
that are defined for that virtual directory. To see the default
documents, select the virtual directory, and double-click the Default
Document icon (in the IIS section).
IIS scans the default document list from top to bottom and returns the first matching page. Using the list in Figure 9,
IIS will check first for a Default.htm file and then for Default.asp,
index.htm, index.html, iisstart.asp, and default.aspx, which is the
home page that most ASP.NET applications use. If IIS doesn't find any
of these pages, either it will return an error message or, if you've
enabled the Browse permission (which usually you won't), it will
provide a file list.
You can easily modify the
default document list using the links in the Actions pane on the right.
Click Add to insert a new default document, click Remove to remove an
existing one, and use the Move Up and Move Down links to rearrange the
order IIS uses when checking for default documents.
6. Custom Error Pages
In any web page request,
there are a number of errors that can occur. The user may attempt to
request a restricted file, the file may not exist, the server may be
too busy, or the page itself may generate an unhandled exception.
Ordinarily, IIS deals with these errors in one of ways. If you're
requesting the page locally (from a browser that's actually running on
the web server), it returns the rich error page shown in Figure 10.
If you're making the request from another computer, IIS keeps good
security in mind and returns a much terser description of the problem,
as shown in Figure 11.
Custom error pages allow
you to replace the standard server-generated pages with something a bit
nicer. For example, you can show an apologetic, user-friendly error
messages that describes the problem, provides an e-mail link to contact
the administrator, or just looks generally less intimidating than the
terse computer jargon of a standard error message.
To configure custom error
pages, select the virtual directory, and double-click the Error Pages
icon (in the IIS section). You'll see a list of HTTP errors that are
mapped to specific HTML error pages (as shown in Figure 12).
You can add or remove items or double-click an error to choose a
different HTML file. You can also click the Edit Feature Settings link
in the Actions pane to set a default error page (which is used when no
other list entry applies).
By default, IIS keeps showing rich error pages (like the one in Figure 10)
for local requests. But if you want to test your rich error pages, you
can turn off this feature. Just click the Edit Feature Settings link,
and choose the "Custom error pages" option, instead of "Detailed errors
for local requests and custom error pages for remote requests."